package educrypt.log;

import java.util.Observable;

public class ObservableLogger extends Observable implements SimpleLogger {

	/* Singleton */
	private ObservableLogger() {
	}

	public static ObservableLogger getInstance() {
		return SingletonHolder.instance;
	}

	private static class SingletonHolder {
		public static final ObservableLogger instance = new ObservableLogger();
	}

	/* END Singleton */

	@Override
	public void log(final String text) {
		this.log(INFO, text);
	}

	@Override
	public void log(final int type, final String text) {
		LogMessage msg = new LogMessage(type, text);
		setChanged();
		notifyObservers(msg);
	}
}
